<?

	require_once 'app.php';

	class Fmgr0v0r01_lnk extends Fmgr0v0r01_app{
		
		var $media_class = 'smlink';
		
		protected $target;
		
		function critical_defaults(){
			return array_merge(parent::critical_defaults(), array(
				'mime' => 'application/x-smuoi-lnk',
			));	
		}
		
		function summary_vars(){
			static $a;
			if(!$a) $a = array_merge_recursive(parent::summary_vars(), array(
				"0:" => array(
					'deskpath'
				)
			));
			return $a;
		}
		
		function get_functions(){
			static $a;
			if(!$a) $a = array_merge(parent::get_functions(), array(
				'filesize'
			));
			return $a;	
		}
			
		function name(){
			return ($t = $this->target()) ? $t->fmrp : parent::name();
		}
		
		function deskpath(){
			return ($t = $this->target()) ? $t->deskpath() : parent::deskpath();
		}
		
		function filesize(){
			return ($t = $this->target()) ? $t->filesize : 0;	
		}
		
		function target(){
			if(is_null($this->target)){
				if($this->target = smopen($this->arguments()->smrf)) return $this->target;
				$this->destroy();
				// quick trick to ensure javascript ignores our json should we make it to the desktop
				$this->allow_read = false;
				return false;
			}
			return $this->target;
		}
		
		function icon($s=32){
			return ($t = $this->target()) ? $t->icon($s) : parent::icon($s);	
		}
		
		function is_destroyable(){
			return (parent::is_destroyable() || !$this->target());	
		}

	}

?>